package role;

import acm.util.RandomGenerator;
import role.Creature;

public class Enemy extends Creature {

    public String getItemDrop() {
        return itemDrop;
    }

    public void setItemDrop(String itemDrop) {
        this.itemDrop = itemDrop;
    }

    private String itemDrop;                 //

    private final RandomGenerator randomGenerator = RandomGenerator.getInstance();
    private static final String[] ENEMY_NAMES = {"石牙野猪", "脓疮恶犬", "钢鬃狼", "丁真", "乌尔扎戈-弱智者", "格罗特·酒鬼", "该隐", "萨弗拉斯", "玛尔嘉尼斯"};           // 敌人名字
    private static final String[] ENEMY_ROLES = { "野兽", "魔兽", "低阶恶魔", "绿皮兽人", "恶棍", "高阶恶魔", "恐虐放血鬼", "神选混沌勇士"};     // 敌人角色
    private static final String[] BOSS_NAMES = {"菲尼克斯", "烂肠", "卡婕琳","如花","魔王1"};           // BOSS名字
    private static final String[] BOSS_ROLES = {"色孽女巫", "神尊大不敬者", "寒冰奇美拉","三头熔岩恶犬","魔王"};     // BOSS角色

    public void generateRandomEnemy(int enemyLevel, int enemyType) {
        int index;  // 用于储存数组下标
        //设置一个小怪等级系数 小怪真实等级为危险系数 +—1
        int levelRandom = randomGenerator.nextInt(-1, 1);
        //判断是哪张大地图
        if (enemyType == 0) {
            // 随机选择一个名字
            index = randomGenerator.nextInt(0, 2);
            name = ENEMY_NAMES[index];
            // 随机选择一个角色
            index = randomGenerator.nextInt(0, 1);
            role = ENEMY_ROLES[index];
        } else if (enemyType == 1) {
            // 随机选择一个名字
            index = randomGenerator.nextInt(3, 5);
            name = ENEMY_NAMES[index];
            // 随机选择一个角色
            index = randomGenerator.nextInt(2, 4);
            role = ENEMY_ROLES[index];
        } else if (enemyType == 2) {
            // 随机选择一个名字
            index = randomGenerator.nextInt(6, 8);
            name = ENEMY_NAMES[index];
            // 随机选择一个角色
            index = randomGenerator.nextInt(5, 7);
            role = ENEMY_ROLES[index];
        }


        // 该敌人的各种属性
        int baseHp;                 // 基础血量
        int baseAttack;             // 基础攻击力
        int hpMaxIncrease;          // 每升一级，血量最大增加多少
        int attackMaxIncrease;      // 每升一级，攻击力最大增加多少
        int baseDefense;//基础防御
        int defenseIncrease;//每生一级 防御力增加

        // 不同角色有不同的基础属性和成长属性
        switch (role) {
            case "野兽":
                baseDefense = 2;
                baseHp = 100;
                baseAttack = 8;
                hpMaxIncrease = 20;
                attackMaxIncrease = 2;
                defenseIncrease = 1;
                break;
            case "魔兽":
                baseDefense = 2;
                baseHp = 100;
                baseAttack = 10;
                hpMaxIncrease = 15;
                attackMaxIncrease = 5;
                defenseIncrease = 1;
                break;
            case "绿皮兽人":
                baseDefense = 2;
                baseHp = 120;
                baseAttack = 20;
                hpMaxIncrease = 15;
                attackMaxIncrease = 7;
                defenseIncrease = 1;
                break;
            case "低阶恶魔":
                baseDefense = 8;
                baseHp = 200;
                baseAttack = 20;
                hpMaxIncrease = 20;
                attackMaxIncrease = 8;
                defenseIncrease = 1;
                break;
            case "恶棍":
                baseDefense = 6;
                baseHp = 190;
                baseAttack = 20;
                hpMaxIncrease = 12;
                attackMaxIncrease = 8;
                defenseIncrease = 2;
                break;
            case "高阶恶魔":
                baseDefense = 10;
                baseHp = 300;
                baseAttack = 30;
                hpMaxIncrease = 15;
                attackMaxIncrease = 9;
                defenseIncrease = 2;
                break;
            case "恐虐放血鬼":
                baseDefense = 5;
                baseHp = 150;
                baseAttack = 45;
                hpMaxIncrease = 12;
                attackMaxIncrease = 12;
                defenseIncrease = 1;
                break;
            case "神选混沌勇士":
                baseDefense = 12;
                baseHp = 275;
                baseAttack = 45;
                hpMaxIncrease = 16;
                attackMaxIncrease = 9;
                defenseIncrease = 3;
                break;
            default:

                baseHp = 0;
                baseAttack = 0;
                hpMaxIncrease = 0;
                attackMaxIncrease = 0;
                defenseIncrease = 0;
                baseDefense = 0;
                break;
        }

        // 随机生成该敌人1级时的属性
        maxHp =  baseHp;
        attack = baseAttack;
        defense = baseDefense;


        // 让该敌人升到危险系数+-1的等级
        for (level = 1; level < enemyLevel + levelRandom; level++) {
            maxHp += randomGenerator.nextInt(0, hpMaxIncrease);
            baseAttack += randomGenerator.nextInt(1, attackMaxIncrease);
            baseDefense += randomGenerator.nextInt(0, defenseIncrease);

        }

        // 将该敌人设置为满血
        curHp = maxHp;
        attack = baseAttack;
        defense = baseDefense;
    }

    public void generateBoss(int boss, int bossNumber) {
        name = BOSS_NAMES[bossNumber];
        role = BOSS_ROLES[bossNumber];
        // 该敌人的各种属性
        int baseHp;                 // 基础血量
        int baseAttack;             // 基础攻击力
        int hpMaxIncrease;          // 每升一级，血量最大增加多少
        int attackMaxIncrease;      // 每升一级，攻击力最大增加多少
        int baseDefense;//基础防御
        int defenseIncrease;//每生一级 防御力增加

        // 不同角色有不同的基础属性和成长属性
        switch (role) {
            case "色孽女巫":
                defenseIncrease = 5;
                baseDefense = 10;
                baseHp = 1000;
                baseAttack = 12;
                hpMaxIncrease = 10;
                attackMaxIncrease = 2;
                break;
            case "神尊大不敬者":
                defenseIncrease = 1;
                baseDefense = 0;
                baseHp = 2500;
                baseAttack = 12;
                hpMaxIncrease = 20;
                attackMaxIncrease = 3;
                break;
            case "寒冰奇美拉":
                defenseIncrease = 2;
                baseDefense = 20;
                baseHp = 1250;
                baseAttack = 20;
                hpMaxIncrease = 12;
                attackMaxIncrease = 5;
                break;
            case "三头熔岩恶犬":
                defenseIncrease = 3;
                baseDefense = 30;
                baseHp = 1250;
                baseAttack = 30;
                hpMaxIncrease = 13;
                attackMaxIncrease = 6;
                break;
            case "魔王":
                defenseIncrease = 4;
                baseDefense = 40;
                baseHp = 5000;
                baseAttack = 200;
                hpMaxIncrease = 10;
                attackMaxIncrease = 10;
                break;
            default:
                defenseIncrease = 0;
                baseDefense = 0;
                baseHp = 0;
                baseAttack = 0;
                hpMaxIncrease = 0;
                attackMaxIncrease = 0;
                break;
        }

        // 随机生成该敌人1级时的属性
        maxHp =  baseHp;
        attack = baseAttack;
        defense = baseDefense;

        //让boss升到 boss级
        for (level = 1; level < boss; level++) {
            maxHp += randomGenerator.nextInt(0, hpMaxIncrease);
            baseAttack += randomGenerator.nextInt(0, attackMaxIncrease);
            baseDefense += randomGenerator.nextInt(0, defenseIncrease);
        }

        // 将该敌人设置为满血
        curHp = maxHp;
        attack =baseAttack;
        defense = baseDefense;
    }

}